import {defineStore} from "pinia";
import {getCityData, getHotSuggestsData} from "@/service/api";

export const useCityStore = defineStore('city',{
    state: ()=>({
        allCities: {},
        currentCity: {
            cityName: '南昌'
        },
        hotSuggests: []
    }),
    getters: {

    },
    actions: {
        async fetchAllCitiesData() {
            const res = await getCityData()
            this.allCities = res.data
            return Promise.resolve(res.data)
        },
        async fetchHotSuggestsData(){
            const res = await getHotSuggestsData()
            this.hotSuggests = res.data
            return Promise.resolve(res.data)
        }
    }
})